package day07;

import java.util.Scanner;

public class   CalAirPrice {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票的原价:");
        double price = scan.nextDouble();

        System.out.println("请输入月份:");
        int month = scan.nextInt();
        if (month < 1 || month > 12) {
            System.out.println("月份输入错误!请重新输入...");
            month = scan.nextInt();
        }

        System.out.println("请选择舱位: 1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();
        if (type < 1 || type > 3) {
            System.out.println("舱位选择错误!请重新输入...");
            type = scan.nextInt();
        }

        double finaPrice = calAirPrice(price,month,type);
        System.out.println("最终价格为:"+finaPrice+"元");

    }
    public static double calAirPrice(double price, int month, int type){
        double finaPrice = 0.0; //最终价格

        //计算过程
        if (month>=5 && month<=12) { //旺季
            switch (type){
                case 1:
                    finaPrice=price*0.9;
                    break;
                case 2:
                    finaPrice=price*0.85;
                    break;
                case 3:
                    finaPrice=price*0.8;
                    break;
            }
        }else { //淡季
            switch (type) {
                case 1:
                    finaPrice = price * 0.7;
                    break;
                case 2:
                    finaPrice = price * 0.65;
                    break;
                case 3:
                    finaPrice = price * 0.6;
                    break;
                }
        }
        return finaPrice;
    }
}
